﻿using AutoMapper;
using Customer.API.Applcation.Command.RefundCommand;
using Customer.Domain;
using Customer.Infrstructre;
using Customer.Infrstructre.ProcurementManager;
using MediatR;
using Microsoft.EntityFrameworkCore;

namespace Customer.API.Applcation.CommandHandlers.RefundCommandHandler
{
    public class RefundAddCommandHandler : IRequestHandler<RefundAddCommand, int>
    {
        IRefundRepository rRep;
        IMapper mapper;

        public RefundAddCommandHandler(IRefundRepository rRep, IMapper mapper)
        {
            this.rRep = rRep;
            this.mapper = mapper;
        }


        public async Task<int> Handle(RefundAddCommand request, CancellationToken cancellationToken)
        {
            return await rRep.AddAsync(mapper.Map<Refund>(request.addDto));
        }
    }
}
